package impl;

import com.github.javafaker.Faker;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Random;

public class Impl_3 {
    Random random = new Random();
    Faker faker = new Faker(Locale.CHINA);
    static String[] qd = {"QQ", "微信", "应用宝", "今日头条", "哔哩哔哩", "广告"};
    static String[] bb = {"1.2.1", "1.2.3", "2.1.1", "2.2.2", "1.5.2", "2.3.5"};
    static String[] yys = {"联通", "电信", "移动"};
    Date s =faker.date().birthday();
    String o = "" + s;


    public String addutd_id() {
        String i = "";
        String[] id = {
                String.format("%02x", 0x52),
                String.format("%02x", 0x00),
                String.format("%02x", random.nextInt(0xff)),
                String.format("%02x", random.nextInt(0xff))
        };
        for (int j = 0; j < id.length; j++) {
            i += id[j];
        }
        return i;
    }


    public String addwmac() {

        return faker.internet().macAddress();
    }


    public String addimsi() {
        return faker.random().hex(15);
    }


    public String addsource_uid() {
        return faker.random().hex(15);
    }


    public String addsource_channel() {

        return qd[random.nextInt(qd.length)];
    }


    public Long addsource_install_server_time() {

        return faker.date().birthday().getTime() / 1000;
    }


    public String addsource_app_version() {
        return bb[random.nextInt(bb.length)];
    }


    public String addip() {
        return faker.internet().ipV4Address();
    }


    public Long addserver_timestamp() {
        return s.getTime()/1000;
    }


    public String adddata_date() {
        DateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);

        Date parse = null;
        try {
            parse = df.parse(o);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        SimpleDateFormat dff = new SimpleDateFormat("yyyy-MM-dd");
        String format = dff.format(parse);
        return format;
    }


    public String adddata_hour()  {
        DateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);

        Date parse = null;
        try {
            parse = df.parse(o);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        SimpleDateFormat dff = new SimpleDateFormat("HH:mm:ss");
        String format = dff.format(parse);

        return format;
    }


    public String addoperator() {
        return yys[random.nextInt(yys.length)];
    }


}
